$().ready( function() {
	var $listForm = $("#listForm");
	var $listTable = $("#listTable");
	var $selectAll = $("#selectAll");
	var $ids = $("#listTable input[name='ids']");
	
	// 全选
	$selectAll.click( function() {
		var $this = $(this);
		var $enabledIds = $("#cartTable input[name='ids']:enabled");
		if ($this.prop("checked")) {
			$enabledIds.prop("checked", true);
			if ($enabledIds.filter(":checked").size() > 0) {
			} else {
			}
		} else {
			$enabledIds.prop("checked", false);
		}
		
		var isChecked = $selectAll.attr("checked");
		var check ;
		//alert("isChecked: " + isChecked);
		if (isChecked=="checked") {
			check = true;
		} else {
			check = false;
		}
		
		$.ajax({
			url: "selectAll.jhtml",
			data:{check:check},
			type: "POST",
			dataType: "json",
			cache: false,
			success: function(data) {
				if (data.message.type == "success") {
					$("#effectivePrice").html(currency(data.effectivePrice, true, true));
				}
			}
		});
	});
	
	// 选择
	$ids.click( function() {
		var $this = $(this);
		if ($this.prop("checked")) {
			$this.closest("tr").addClass("selected");
		} else {
			$this.closest("tr").removeClass("selected");
			if ($("#listTable input[name='ids']:enabled:checked").size() > 0) {
			} else {
			}
		}
	});
});